package work01;

public class work5checkNumber {
    public static void main(String[] args) {
        int count = 0;
        for (int i = 1; i <= 1000; i++) {
            if(HuiWen(i) && IsPrime(i)){
                System.out.print(i+" ");
                count++;
                if (count % 10 == 0){
                    System.out.println(" ");
                }
            }
        }
    }

    static boolean HuiWen(int num) {
        String number = String.valueOf(num);
        int len = number.length();
        for (int i = 0; i < len / 2; i++) {
            if (number.charAt(i) != number.charAt(len - i - 1)) {
                return false;
            }
        }
        return true;
    }

    static boolean IsPrime(int number) {
        if (number < 2) {
            return false;
        }
        if (number == 2) {
            return true;
        }
        if (number % 2 != 0) {
            return false;
        }
        for (int i = 3; i < Math.sqrt(number); i++) {
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
}
